import {ref,onMounted} from 'vue';
let TargetDom = ref();
let time_:any = null;
let TargetDomSize = ref({
    width:0,
    height:0
})
const resizeTimeFun = () =>{
    TargetDomSize.value.width = TargetDom.value.clientWidth;
    TargetDomSize.value.height = TargetDom.value.clientHeight;
}
const onResize = () =>{
    clearTimeout(time_);
    time_ = setTimeout(resizeTimeFun,100);
}
export const onObserver = (dom:HTMLDivElement) =>{
    TargetDom.value = dom;
    const resizeObserve = new ResizeObserver(() => onResize());
    resizeObserve.observe(TargetDom.value);
    return {...TargetDomSize.value}
}
export const targetSize = TargetDomSize